const Sequelize = require('sequelize');
const DB = require("../config/dbconfig");

const userModel =  DB.define('user_tab', {
    user_id: {
      type: Sequelize.INTEGER,
      allowNull: false,
      primaryKey: true,
      comment: "用户id"
    },
    nickname: {
      type: Sequelize.STRING(20),
      allowNull: false,
      defaultValue: "",
      comment: "昵称"
    },
    password: {
      type: Sequelize.STRING(20),
      allowNull: false,
      defaultValue: "",
      comment: "密码"
    },
    realname: {
      type: Sequelize.STRING(7),
      allowNull: true,
      comment: "真名"
    },
    age: {
      type: Sequelize.INTEGER,
      allowNull: true,
      comment: "年龄"
    },
    occupation: {
      type: Sequelize.STRING(7),
      allowNull: true,
      comment: "职业"
    },
    introduction: {
      type: Sequelize.STRING(255),
      allowNull: true,
      comment: "个人介绍"
    },
    is_member: {
      type: Sequelize.BOOLEAN,
      allowNull: true,
      comment: "是否会员"
    },
    avatar: {
      type: Sequelize.STRING(15000),
      allowNull: true,
      comment: "头像"
    },
    address: {
      type: Sequelize.STRING(7),
      allowNull: true,
      comment: "地址"
    },
    role: {
      type: Sequelize.INTEGER,
      allowNull: true,
      comment: "角色，0为用户，1为管理员",
      defaultValue:0
    },
    create_time: {
      type: Sequelize.DATE,
      allowNull: true,
      comment: "注册时间",
      defaultValue:""
    },
    is_delete:{
      type:Sequelize.INTEGER(2),
      comment:"是否删除,0是未删除，1是删除"
    },
    gender:{
      type:Sequelize.INTEGER(1),
      comment:"默认为0，1是女生，2是男生"
    },
    phone:{
      type:Sequelize.STRING(11),
      comment:"手机号码"
    },
    email:{
      type:Sequelize.STRING(255),
      comment:"邮箱"
    },
    is_super:{
      type:Sequelize.INTEGER(1),
      comment:"是否为超级管理员，1是，0不是"
    },
    openid:{
      type:Sequelize.STRING(300),
      comment:"小程序用户的openid,唯一标识"
    },

  }, {
    Sequelize,
    tableName: 'user_tab',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "user_id" },
        ]
      },
    ]
  });

module.exports = userModel
